maintainer="omni <omni+alpine@hack.org>"
pkgname=neovide
pkgver=0.13.3
pkgrel=0
pkgdesc="No Nonsense Neovim Client in Rust"
url="https://neovide.dev/"
arch="aarch64 x86_64" # limited by skia-bindings crate (bin/fetch-gn)
license="MIT"
depends="neovim"
makedepends="cargo
	cargo-auditable
	clang-dev
	cmake
	curl
	expat-dev
	freetype-dev
	gtk+3.0
	gn
	harfbuzz-dev
	icu-dev
	libjpeg-turbo-dev
	libpng-dev
	libwebp-dev
	python3
	samurai
	sdl2
	zlib-dev
	"
subpackages="$pkgname-doc"
source="$pkgname-$pkgver.tar.gz::https://github.com/neovide/neovide/archive/refs/tags/$pkgver.tar.gz"

prepare() {
	default_prepare

	cargo fetch --target="$CTARGET" --locked
}

build() {
	export SKIA_USE_SYSTEM_LIBRARIES=true
	export FORCE_SKIA_BUILD=true
	export SKIA_GN_COMMAND=gn
	export SKIA_NINJA_COMMAND=ninja
	export CC=clang
	export CXX=clang++

	RUST_BACKTRACE=full cargo auditable build --release --frozen

	# May contain interesting information
	grep "Skia args" target/release/build/skia-bindings-*/output
}

check() {
	cargo test --all --frozen
}

package() {
	install -Dm0755 -t "$pkgdir"/usr/bin/ target/release/$pkgname
	install -Dm0644 -t "$pkgdir"/usr/share/applications/ \
		assets/$pkgname.desktop
	install -Dm0644 -t "$pkgdir"/usr/share/icons/hicolor/scalable/apps/ \
		assets/$pkgname.svg

	install -Dm0644 -t "$pkgdir"/usr/share/licenses/$pkgname/ LICENSE

	install -Dm0644 -t "$pkgdir"/usr/share/doc/$pkgname/ \
		website/docs/command-line-reference.md \
		website/docs/commands.md \
		website/docs/config-file.md \
		website/docs/configuration.md \
		website/docs/editing-with-external-tools.md \
		website/docs/faq.md \
		website/docs/features.md \
		website/docs/troubleshooting.md

}

sha512sums="
3765de908a0364e74d9273aba5724977bdd5a155f388db78cef268e426cdf899bb24e001b9f6055d2641e35ea86b0d7df8e8803ab502f2de4d4f9511c7322d4c  neovide-0.13.3.tar.gz
"
